package com.dygg.bigfish.controller;

import com.dygg.bigfish.dao.InvitationDao;
import com.dygg.bigfish.entity.Content;
import com.dygg.bigfish.entity.Invitation;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "contentServlet", value = "/contentServlet")
public class ContentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String invId = request.getParameter("invId");
        List<Content> contents = new InvitationDao().queryContentByInvitationId(invId);
        Invitation invitation = new InvitationDao().queryInvitationsById(invId);
        request.setAttribute("invitation",invitation);
        request.setAttribute("contents",contents);
        request.getRequestDispatcher("show.jsp").forward(request,response);
    }
}
